home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / gemfut15.lzh / AESUTOB4.C < prev    next >
C/C++ Source or Header  |  1990-05-27  |  2KB  |  86 lines

  1.  
  2. /**************************************************************************
  3.  *
  4.  * AESFAST PD utilties.
  5.  *
  6.  *  Object-related utilities 4...
  7.  *   obj_rbfind
  8.  *   obj_parent
  9.  *   obj_rbselect
  10.  *
  11.  * 05/26/90 - v1.4 
  12.  *            >  Added obj_rbselect().
  13.  *************************************************************************/
  14.  
  15. #include <gemfast.h>
  16.  
  17. /*-------------------------------------------------------------------------
  18.  * obj_rbfind - Extended radio button finder.
  19.  *-----------------------------------------------------------------------*/
  20.  
  21. int
  22. obj_rbfind(tree, parent, rbstate)
  23.     register OBJECT *tree;
  24.     register int    parent;
  25.     register char   rbstate;
  26. {
  27.     register int kid;
  28.  
  29.     kid = tree[parent].ob_head;
  30.  
  31.     while ( (kid != parent) && (kid >= R_TREE) ) {
  32.         if (tree[kid].ob_state & rbstate) {
  33.             return(kid);
  34.         }
  35.         kid = tree[kid].ob_next;
  36.     }
  37.     return NO_OBJECT;
  38. }
  39.  
  40. /*-------------------------------------------------------------------------
  41.  * obj_parent - Find the parent of a given child object.
  42.  *-----------------------------------------------------------------------*/
  43.  
  44. int
  45. obj_parent(tree, curobj)
  46.     register OBJECT *tree;
  47.     register int    curobj;
  48. {
  49.     register int    nxtobj;
  50.                  
  51.     if (curobj == R_TREE)    /* The root of a tree has no parent */
  52.         return R_TREE;
  53.  
  54.     while(1) {
  55.         nxtobj = tree[curobj].ob_next;
  56.         if (tree[nxtobj].ob_tail == curobj)
  57.             return(nxtobj);
  58.         curobj = nxtobj;
  59.     }
  60. }
  61.  
  62. /*-------------------------------------------------------------------------
  63.  * obj_rbselect - Set a radio button to SELECTED, de-sel others in the group.
  64.  *-----------------------------------------------------------------------*/
  65.  
  66. int
  67. obj_rbselect(ptree, selobj, state)
  68.     register OBJECT *ptree;
  69.     register int    selobj;
  70.     register int    state;
  71. {
  72.     register int    oldobj;
  73.  
  74.     if (selobj <= R_TREE) {
  75.         return NO_OBJECT;
  76.     }
  77.  
  78.     oldobj = obj_rbfind(ptree, obj_parent(ptree, selobj), state);
  79.     if (oldobj != NO_OBJECT) {
  80.         ptree[oldobj].ob_state &= ~state;
  81.     }
  82.     ptree[selobj].ob_state |= state;
  83.     return oldobj;
  84. }
  85.  
  86.